SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION dbo.fnGetActualNAV 
(
	-- Add the parameters for the function here
	@ExportId INT, @NAVDate DATETIME 
)
RETURNS DECIMAL(38,10)
AS
BEGIN
	-- Declare the return variable here
	DECLARE @ResultVar DECIMAL(38,10)

	-- Add the T-SQL statements to compute the return value here
SET @ResultVar=	(SELECT 
		CASE WHEN dn.NAVShare < 1 THEN dn.EstNAVShare ELSE dn.NAVShare END
	
	 FROM FSFundModel.Reporting.DailyNAV dn
	WHERE dn.ExportId = @ExportId AND dn.NAVDate = @NAVDate 
	  )

	  RETURN @ResultVar 
END
GO
